package com.trade.dao.impl;

import java.util.Collections;
import java.util.List;

import com.trade.common.dao.impl.GenericDao;
import com.trade.dao.IReposityDao;
import com.trade.exception.PersistenceException;
import com.trade.model.Reposity;

/**
 * @author Lin Yang
 * 
 */
public class ReposityDaoImpl extends GenericDao<Reposity, Long> implements IReposityDao {
    public List<Reposity> getAllReposity() throws PersistenceException {
        try {
            List<Reposity> repositys = find("from Reposity");

            if (repositys == null || repositys.size() == 0) {
                return Collections.emptyList();
            }

            return repositys;
        } catch (Exception e) {
            throw new PersistenceException("查询商品入库失败", e);
        }
    }

    public List<Reposity> getReposityByLogistic(String logisticNumber) throws PersistenceException {
        try {
            List<Reposity> repositys = find("from Reposity where logisticNumber like ?", "%" + logisticNumber + "%");

            if (repositys == null || repositys.size() == 0) {
                return Collections.emptyList();
            }

            return repositys;
        } catch (Exception e) {
            throw new PersistenceException("查询商品入库失败", e);
        }
    }
}
